<?php
namespace app\admin\middleware;

class Auth
{
    public function handle($request,\Closure $next){
        if(empty(session(config('admin.session_admin')))&&!preg_match('/login/',$request->pathinfo())){
            return redirect(url('login/index'));
        }
        //前置中间件
        $response = $next($request);
//        if(empty(session(config('admin.session_admin')))&&$request->controller()!='Login'){
//            return redirect(url('login/index'));
//        }
//        dump($request->controller());
        return $response;
        //后置中间件
    }

    /**
     * 中间件结束调度
     * @param \think\Response $response
     */
    public function end(\think\Response $response){

    }
}